import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import '../../api/DeApi.dart';
import '../../api/OrderApi.dart';
import '../../utils/ToastUtils.dart';
import '../Login.dart';
import '../search.dart';

class SettingPage extends StatefulWidget {
  const SettingPage({super.key});

  @override
  State<SettingPage> createState() => _SettingPageState();
}

class _SettingPageState extends State<SettingPage> {
  // 在Login页面的State类中
  final OrderApi _orderApi = OrderApi();
  final DeApi _deApi = DeApi();


  void _fetchOrders() async {
      final response = await _orderApi.getDevice();
      print("dddddddd $response");
  }


  void _fetchOrdersss() async {
    final response = await _deApi.getRouters();
    print(response.data);
    print("dddddddd1 $response");
  }

  void _fetchOrdersss2() async {
    final response = await _deApi.getRouters2();

    print("dddddddd2 $response");
  }


  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        children: [
          //按钮
          ElevatedButton(
            onPressed: (){
              Navigator.of(context).push(
                //跳转路由
                  MaterialPageRoute(builder: (BuildContext context){
                    return const SearchPage();
                  })
              );
            },
            child: const Text("基本路由跳转"),
          ),


          ElevatedButton(
          onPressed: () => ToastUtils.showToast("普通 Toast"), // 按钮点击事件
          child: Text("显示普通 Toast"), // 按钮上的文字
          ),
          SizedBox(height: 20), // 间隔组件，垂直间隔 20 像素


          const SizedBox(height: 20,),
          ElevatedButton(
            onPressed: (){
              Navigator.of(context).push(
                //跳转路由
                  MaterialPageRoute(builder: (BuildContext context){
                    return Login();
                  })
              );
            },
            child: const Text("ddd"),
          ),



          const SizedBox(height: 20,),
          ElevatedButton(
            onPressed: (){
              Navigator.pushNamed(context, "/search");
            },
            child: const Text("命名路由跳转"),
          ),

          const SizedBox(height: 20,),


          ElevatedButton(
            onPressed: _fetchOrders,
            child: const Text("调用接口1"),
          ),

          ElevatedButton(
            onPressed: _fetchOrdersss,
            child: const Text("调用接口2"),
          ),


          ElevatedButton(
            onPressed: _fetchOrdersss2,
            child: const Text("调用接口3"),
          ),


          const SizedBox(height: 20,),
          ElevatedButton(
            onPressed: (){
              Navigator.pushNamed(context, "/device");
            },
            child: const Text("de"),
          ),


          const SizedBox(height: 20,),
          ElevatedButton(
            onPressed: (){
              Navigator.pushNamed(context, "/qrcode");
            },
            child: const Text("qqqq"),
          ),



          ElevatedButton(
            onPressed: (){
              BrnDialogManager.showConfirmDialog(context,
                  title: "标题内容标题内容标题内容标题内容",
                  cancel: '取消',
                  confirm: '确定',
                  barrierDismissible: true,
                  onCancel: () {
                    Navigator.of(context).pop();
                    BrnToast.show("取消", context);
                  },
                  onConfirm: () {
                    BrnToast.show("确定", context);
                  },

                );
            },
            child: const Text("xxxxx"),
          ),



        ],
      ),
    );
  }
}









